package interfaceGrafica;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import javax.swing.JTextField;

import servicos.Servicos;

public class JanelaCpf extends SuperVendas {

	private Servicos servicos;
	private JTextField txtCpf;
	private JLabel lblCpf, lblGamb, lblGamb2;
	private JButton btnOk, btnCancelar;
	private JPanel centro;

	public JanelaCpf(Servicos servicos) {
		super(servicos);
		this.setTitle("Inserir CPF");
		this.servicos = servicos;
		this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		this.setSize(200, 100);

		JPanel jPanel1 = new JPanel();
		JPanel jPanel2 = new JPanel();
		JPanel jPanel3 = new JPanel();
		Container janela;

		janela = getContentPane();
		janela.setLayout(new BorderLayout());

		jPanel1.setLayout(new FlowLayout());
		jPanel2.setLayout(new FlowLayout());
		jPanel3.setLayout(new FlowLayout());

		lblGamb = new JLabel("");
		jPanel1.add(lblGamb);

		lblGamb2 = new JLabel("");
		jPanel2.add(lblGamb2);

		lblCpf = new JLabel("CPF:");
		jPanel1.add(lblCpf);

		txtCpf = new JTextField(12);
		jPanel2.add(txtCpf);

		btnOk = new JButton("OK");
		InserirCpf inserirCpf = new InserirCpf();
		btnOk.addActionListener(inserirCpf);
		jPanel3.add(btnOk);

		btnCancelar = new JButton("Cancelar");
		Cancelar cancelar = new Cancelar();
		btnCancelar.addActionListener(cancelar);
		jPanel3.add(btnCancelar);

		janela.add(jPanel1, BorderLayout.WEST);
		janela.add(jPanel2, BorderLayout.CENTER);
		janela.add(jPanel3, BorderLayout.SOUTH);

		this.setVisible(true);

	}

	private class InserirCpf implements ActionListener {

		public void actionPerformed(ActionEvent e) {
			iniciaVariaveisVenda(txtCpf.getText());
			dispose();
		}

	}

	private class Cancelar implements ActionListener {

		public void actionPerformed(ActionEvent e) {
			iniciaVariaveisVenda("");
			dispose();
		}

	}

}
